//
//  ScrollView.m
//  UI_07homeworkNavigationAndGesture
//
//  Created by Gavin–fan on 16/6/14.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "ScrollView.h"

@implementation ScrollView



-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        self.imagesArray = [NSArray array];
        
//    self.contentSize = CGSizeMake(CGRectGetWidth(self.bounds) * self.imagesArray.count, CGRectGetHeight(self.bounds));

     self.showsHorizontalScrollIndicator = NO;
     self.showsVerticalScrollIndicator = NO;
        self.pagingEnabled = YES;
        
        
        
        
//        [self setSomePics];
    }
    return self;
}
- (void)setSomePics
{
    
    for (int i = 0; i < _imagesArray.count; i++) {
        UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(i * CGRectGetWidth(self.bounds), 0, CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds))];
        
        imageView.image = _imagesArray[i];
        
        [self addSubview:imageView];
        [imageView release];
    }
    
    
}

-(void)setImagesArray:(NSArray<UIImage *> *)imagesArray{
    
    if (_imagesArray != imagesArray) {
        [imagesArray retain];
        _imagesArray = imagesArray;
        [imagesArray release];
    }
    
     [self setSomePics];
     self.contentSize = CGSizeMake(CGRectGetWidth(self.bounds) * self.imagesArray.count, CGRectGetHeight(self.bounds));

    
}



@end
